package com.lhnstart.learn.bases.collection_;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author lhn
 * @date 2023/10/30 21:05
 * @since 1.0.0
 **/
public class CollectionIterator {

    public static void main(String[] args) {
        Collection col = new ArrayList();
        col.add(1);
        col.add(2);
        col.add(3);
        Iterator iterator = col.iterator();
        // 使用 while 循环遍历
        while (iterator.hasNext()) {
            Object next = iterator.next();
            System.out.println("next = " + next);
        }
        while (iterator.hasNext()) {
            Object next = iterator.next();
        }
        for (Object o : col) {

        }
    }

}